import router from './router'
import store from '@/store'
import { Toast } from 'vant'
import { nativeHandler } from 'qmp-native'

router.beforeEach(async(to, from, next) => {
  if (store.getters.userInfo && store.getters.userInfo.positionCodes && store.getters.userInfo.positionCodes.length > 0) {
    next()
    return
  }
  store.dispatch('getMyPositionCode').then(data => {
    next()
  }).catch(() => {
    Toast('暂无职务权限')
    setTimeout(() => {
      nativeHandler('closeWeb', {})
    }, 2000)
  })
})

router.afterEach(() => {

})
